/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.skill.executor;

import static com.lineage.server.model.skill.L1SkillId.EARTH_BIND;
import static com.lineage.server.model.skill.L1SkillId.FREEZING_BLIZZARD;
import static com.lineage.server.model.skill.L1SkillId.FREEZING_BREATH;
import static com.lineage.server.model.skill.L1SkillId.ICE_LANCE;

import com.lineage.server.model.L1Character;
import com.lineage.server.model.L1CurseParalysis;
import com.lineage.server.model.Instance.L1MonsterInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.skill.L1SkillExecutor;
import com.lineage.server.packetserver.S_Paralysis;
import com.lineage.server.packetserver.S_Poison;

/**
 * Class <code>CurseParalyze</code> 法师魔法:木乃伊的诅咒 (80/0/2).
 * 有一定的机率麻痹目标，使之无法动弹。麻痹期间的长短依照施法者等级而定（每次使用增加500点邪恶值）
 * 
 * 攻击距离：2单位
 * 
 * @author jrwz
 * @version 2012-7-24下午09:15:45
 * @see com.lineage.server.model.skill.executor
 * @since JDK1.7
 */
public final class CurseParalyze extends L1SkillExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static L1SkillExecutor get() {
        return new CurseParalyze();
    }

    /** 法师魔法:木乃伊的诅咒 (80/0/2). */
    private CurseParalyze() {
    }

    @Override
    public void execute(final L1Character user, final L1Character cha,
            final L1Character target, final int targetID, final int skillId,
            final int getBuffIconDuration) {
        if (!cha.hasSkillEffect(EARTH_BIND) && !cha.hasSkillEffect(ICE_LANCE)
                && !cha.hasSkillEffect(FREEZING_BLIZZARD)
                && !cha.hasSkillEffect(FREEZING_BREATH)) {
            if (cha instanceof L1PcInstance) {
                L1CurseParalysis.curse(cha, 8000, 16000);
            } else if (cha instanceof L1MonsterInstance) {
                L1CurseParalysis.curse(cha, 8000, 16000);
            }
        }
    }

    @Override
    public void stop(final L1Character cha, final int skillId) {
        if (cha instanceof L1PcInstance) {
            final L1PcInstance pc = (L1PcInstance) cha;
            pc.sendPackets(new S_Poison(pc.getId(), 0));
            pc.broadcastPacket(new S_Poison(pc.getId(), 0));
            pc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_PARALYSIS, false));
        }
    }
}
